package com.sojson.config.mybatis.sqlformat;

import com.p6spy.engine.spy.appender.MessageFormattingStrategy;

import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.StrUtil;

/**
 * Sql解析输出
 * 
 * @author liu
 * @date 2024-02-07
 */
public class GmpLineFormat implements MessageFormattingStrategy {

    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared,
        String sql, String url) {
        if (StrUtil.isNotBlank(sql)) {
            return StrFormatter.format("耗时: {}ms, sql=====>\n{}", elapsed, sql);
        }
        return "";
    }

}